<template>
  <!-- 企业信息列表详情 -->
  <div class="authentication">
    <!-- 选取企业列表下拉框 -->
    <div class="qy" style="width: 50%">
      <label>当前企业： </label>

      <el-select placeholder="请选择" style="width: 50%" v-model="userid" @change="search">
        <el-option v-for="item in usrlist" :key="item.companyId" :value="item.companyId" :label="item.companyName"> </el-option>
      </el-select>
    </div>
    <el-form :model="ruleForm" label-width="200px" class="demo-ruleForm">
      <!-- 展示区域 -->
      <el-form-item label="企业营业执照" prop="img">
        <div class="shangchuan">
          <el-upload cover disabled class="avatar-uploader" action="" accept="image/jpg,image/png,image/jpeg">
            <img :src="`${baseurl}${companyurl}`" class="avatar" />
          </el-upload>
        </div>
      </el-form-item>
      <el-form-item label="企业名称">
        <el-input v-model="ruleForm.companyName"  :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="统一社会信用代码">
        <el-input v-model="ruleForm.companyCode"  :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="营业执照有效期">
        <el-input v-model="ruleForm.createDate"  :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="注册地址"  >
        <el-input type="textarea" v-model="ruleForm.companyAddress" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="法人身份证">
        <div class="shangchuan">
          <!-- 身份证正面面 -->
          <el-upload disabled class="avatar-uploader" action="" accept="image/jpg,image/png,image/jpeg">
            <img :src="`${baseurl}${Idcasta}`" class="avatar" />
          </el-upload>
          <!-- 身份证背面 -->
          <el-upload disabled class="avatar-uploader" action="" accept="image/jpg,image/png,image/jpeg">
            <img :src="`${baseurl}${Idcastb}`"  class="avatar" />
          </el-upload>
        </div>
      </el-form-item>
      <el-form-item label="法人身份证号码">
        <el-input v-model="ruleForm.legalIdNumber"  :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="法人手机号">
        <el-input v-model="ruleForm.legalPhone" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="ruleForm.companyEmail" :disabled="true"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { Companydetails } from './index'

//import qs from 'qs'
import { getItem } from '@/utils/store'

export default {
  data() {
    return {
      userid: '',
      companyurl:'',
      Idcasta:'',
      Idcastb:'',
      ruleForm: {}, //用户企业数据
      usrlist: null, // 企业的下拉框数据
      baseurl:''
          
    
      
    }
  },
  created() {
    this.usrlist = getItem('USER_INFO').data.data.companyList
  
    this.userid=this.usrlist[0].companyId
    this.search(this.userid)
  },
  methods: {
      /* 查询企业详情 */
    async search(id) {
      try {
        const { data } = await Companydetails(id)
        if (data.code == 0) {
          this.ruleForm = data.data
          console.log(this.ruleForm);
          this.baseurl=getItem('USER_INFO').config.baseURL
          this.companyurl=this.ruleForm.companyLicense
          this.Idcasta=this.ruleForm.legalIdBackside
          this.Idcastb=this.ruleForm.legalIdFrontside
          this.$message.success('查询企业详情成功')
        }
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style lang="less" scoped>
.authentication {
  .qy {
    margin-bottom: 30px;
    width: 50%;
  }
  margin: 40px;
  .demo-ruleForm {
    width: 800px;
    .shangchuan {
      display: flex;
      justify-content: space-around;
    }
    .avatar-uploader .el-upload {
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
      .avatar-uploader-icon {
        margin-right: 80px;
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
        border: 1px solid #777;
      }
      .avatar {
        width: 178px;
        height: 178px;
        display: block;
      }
    }
  }
}
</style>